#!/bin/bash

# Take the first argument
command=$1
# Shift the arguments so we can process the rest
shift

# Use the Master channel
#m=Master
# Interval is either 1 or whatever is supplied as the second argument
i=${1:-1}

level() {
  echo $(pamixer --get-volume)
}

state() {
  isMuted=$(pamixer --get-mute)
  [[ $isMuted = 'false' ]] && echo 'Vol.'
  [[ $isMuted = 'true' ]] && echo 'Muted'
}

case $command in
	-|down) status=$(pamixer -d ${i});;
	+|up) status=$(pamixer -i ${i});;
	!|toggle) status=$(pamixer -t);;
	*) status=$(pamixer --get-mute);;
esac

level=$(level "$status")
state=$(state "$status" | awk '{print toupper($0)}')

notify-send "Volume" "${state} " -h int:value:${level} -t 500 -u low

